//:C06:MemFun1.cpp
// Applying pointers to member functions.
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
#include "../purge.h"
using namespace std;

class Shape
{
    public:
        virtual void draw() = 0;
        virtual ~Shape(){}
};

class Circle : public Shape
{
    public:
        virtual void draw()
        {
            cout << "Circle::Draw()" << endl;
        }
        ~Circle() 
        {
            cout << "Circle::~Circle()" << endl;
        }
};

class Square : public Shape
{
    public:
        virtual void draw()
        {
            cout << "Square::Draw()" << endl;
        } 
        ~Square()
        {
            cout << "Square::~Shape()" << endl;
        }
};

int main(void)
{
    vector<Shape*> vs;
    vs.push_back(new Circle);
    vs.push_back(new Square);
    for_each(vs.begin(), vs.end(), mem_fun(&Shape::draw));
    purge(vs);
}